﻿using System.Xml.Serialization;

namespace Toybox.NicoSharp.RSS.Primitives
{
	using Utilities;

	[XmlRoot("rss")]
	public abstract class AbstractRSS
	{

		#region Public Members

		[XmlAttribute]
		public string version;

		#endregion Public Members


		#region Protected Methods

		protected static string GetQuery()
		{
			return "rss=2.0";
		}

		protected static T Get<T>(string url)
		{
			string xml = NicoWebClient.Get(url);
			return Deserializer.XmlDeserializer<T>(xml);
		}

		#endregion Protected Methods


		#region [SubClass]

		/// <summary>
		/// Itemクラス
		/// </summary>
		public class Item
		{
			/// <summary>
			/// タイトル
			/// </summary>
			public string title;

			/// <summary>
			/// リンク
			/// </summary>
			public string link;

			/// <summary>
			/// GUID
			/// </summary>
			/// <remarks>Globally Unique Identifier</remarks>
			public GUID guid;

			/// <summary>
			/// 日時
			/// </summary>
			public string pubDate;

			/// <summary>
			/// 説明
			/// </summary>
			public string description;
		}

		/// <summary>
		/// GUIDクラス
		/// </summary>
		public class GUID
		{
			[XmlAttribute]
			public bool isPermaLink;

			[XmlText]
			public string innerText;
		}

		#endregion [SubClass]

	}
}
